package com.qingneng.budget.web;

import java.util.List;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.Action;
import com.qingneng.budget.service.sdk.IWorkBudgetService;
import com.qingneng.budget.util.BaseAction;
import com.qingneng.budget.vo.BudgetFeeDoInfo;

public class LoadFeeItemAction extends BaseAction{
	
	private static final Logger logger = Logger.getLogger(LoadBudgetItemAction.class);
	
	public int project_workinfo_id;
	
	
	public int getProject_workinfo_id() {
		return project_workinfo_id;
	}
	public void setProject_workinfo_id(int project_workinfo_id) {
		this.project_workinfo_id = project_workinfo_id;
	}

	private List rows = null;
	
	private Integer total;
	
	public List getRows() {
		return rows;
	}
	public void setRows(List rows) {
		this.rows = rows;
	}
	public Integer getTotal() {
		return total;
	}
	public void setTotal(Integer total) {
		this.total = total;
	}

	public IWorkBudgetService workBudgetService;
	
	public LoadFeeItemAction(){
		
	}
	public LoadFeeItemAction(IWorkBudgetService workBudgetService){
		this.workBudgetService = workBudgetService;
	}
	
	public String execute(){
		// 判断是否已经有取费表计算结果
		if(logger.isDebugEnabled()){
			logger.debug("+++ begin execute LoadFeeItemAction +++ ");
		}
		BudgetFeeDoInfo bean = new BudgetFeeDoInfo();
		bean.setProject_workinfo_id(project_workinfo_id);
		
		logger.info("工程id-project_workinfo_id:"+project_workinfo_id);
		
		List feeDoInfoList = workBudgetService.getBudgetFeeDoInfo(bean);

		if(feeDoInfoList!=null && feeDoInfoList.size()>0){
			logger.info("工程id-project_workinfo_id:"+project_workinfo_id+"：有取费结果");
			rows = feeDoInfoList;
			total = new Integer(1000);
		}else{
			logger.info("工程id-project_workinfo_id:"+project_workinfo_id+"-无取费结果，获取取费表模板");
			rows = workBudgetService.getFeeItem();
			total = new Integer(1000);
		}
	
		return Action.SUCCESS;
	}

}
